package com.wz.project.sap.POST_TMDATA_SERIAL.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.wz.framework.aspectj.lang.annotation.Log;
import com.wz.framework.aspectj.lang.enums.BusinessType;
import com.wz.project.sap.POST_TMDATA_SERIAL.domain.YppRfcPostTmdataSerial;
import com.wz.project.sap.POST_TMDATA_SERIAL.service.IYppRfcPostTmdataSerialService;
import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.common.utils.poi.ExcelUtil;
import com.wz.framework.web.page.TableDataInfo;

/**
 * 生产订单入库SERIALController
 * 
 * @author wz
 * @date 2022-09-20
 */
@Controller
@RequestMapping("/POST_TMDATA_SERIAL/POST_TMDATA_SERIAL")
public class YppRfcPostTmdataSerialController extends BaseController
{
    private String prefix = "POST_TMDATA_SERIAL/POST_TMDATA_SERIAL";

    @Autowired
    private IYppRfcPostTmdataSerialService yppRfcPostTmdataSerialService;

    @RequiresPermissions("POST_TMDATA_SERIAL:POST_TMDATA_SERIAL:view")
    @GetMapping()
    public String POST_TMDATA_SERIAL()
    {
        return prefix + "/POST_TMDATA_SERIAL";
    }

    /**
     * 查询生产订单入库SERIAL列表
     */
//    @RequiresPermissions("POST_TMDATA_SERIAL:POST_TMDATA_SERIAL:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YppRfcPostTmdataSerial yppRfcPostTmdataSerial)
    {
        startPage();
        List<YppRfcPostTmdataSerial> list = yppRfcPostTmdataSerialService.selectYppRfcPostTmdataSerialList(yppRfcPostTmdataSerial);
        return getDataTable(list);
    }

    /**
     * 导出生产订单入库SERIAL列表
     */
//    @RequiresPermissions("POST_TMDATA_SERIAL:POST_TMDATA_SERIAL:export")
    @Log(title = "生产订单入库SERIAL", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YppRfcPostTmdataSerial yppRfcPostTmdataSerial)
    {
        List<YppRfcPostTmdataSerial> list = yppRfcPostTmdataSerialService.selectYppRfcPostTmdataSerialList(yppRfcPostTmdataSerial);
        ExcelUtil<YppRfcPostTmdataSerial> util = new ExcelUtil<YppRfcPostTmdataSerial>(YppRfcPostTmdataSerial.class);
        return util.exportExcel(list, "POST_TMDATA_SERIAL");
    }

    /**
     * 新增生产订单入库SERIAL
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存生产订单入库SERIAL
     */
    @RequiresPermissions("POST_TMDATA_SERIAL:POST_TMDATA_SERIAL:add")
    @Log(title = "生产订单入库SERIAL", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YppRfcPostTmdataSerial yppRfcPostTmdataSerial)
    {
        return toAjax(yppRfcPostTmdataSerialService.insertYppRfcPostTmdataSerial(yppRfcPostTmdataSerial));
    }

    /**
     * 修改生产订单入库SERIAL
     */
    @GetMapping("/edit/{ZDOCNO}")
    public String edit(@PathVariable("ZDOCNO") String ZDOCNO, ModelMap mmap)
    {
        YppRfcPostTmdataSerial yppRfcPostTmdataSerial = yppRfcPostTmdataSerialService.selectYppRfcPostTmdataSerialById(ZDOCNO);
        mmap.put("yppRfcPostTmdataSerial", yppRfcPostTmdataSerial);
        return prefix + "/edit";
    }

    /**
     * 修改保存生产订单入库SERIAL
     */
    @RequiresPermissions("POST_TMDATA_SERIAL:POST_TMDATA_SERIAL:edit")
    @Log(title = "生产订单入库SERIAL", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YppRfcPostTmdataSerial yppRfcPostTmdataSerial)
    {
        return toAjax(yppRfcPostTmdataSerialService.updateYppRfcPostTmdataSerial(yppRfcPostTmdataSerial));
    }

    /**
     * 删除生产订单入库SERIAL
     */
    @RequiresPermissions("POST_TMDATA_SERIAL:POST_TMDATA_SERIAL:remove")
    @Log(title = "生产订单入库SERIAL", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(yppRfcPostTmdataSerialService.deleteYppRfcPostTmdataSerialByIds(ids));
    }
}
